<?php
namespace frontend\controllers;

use frontend\models\Banner;
use frontend\models\Project;
use frontend\models\Team;
use backend\models\Config;
use common\components\FrontBaseController;
use Yii;
use common\helps\tools;
use common\helps\code;
/**
 * Index controller
 */
class IndexController extends FrontBaseController
{

    public $modelClass = 'common\models\Banner';
    public function init()
    {
        parent::init();
    }

    /**
     * 获取配置信息
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionGetConfigInfo(){
        $model = new Config();
        $total_data = $model->getConfigInfo();
        return code::success($total_data);

    }

    /**
     * 获取banner
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionGetBannerList(){
        $request =$this->request;
        $model = new Banner();
        $params = $request->queryParams;
        $total_data = $model->getBannerList($params);
        $data = tools::getPageData($total_data,empty($params['page_size'])?'':$params['page_size'],empty($params['page'])?'':$params['page']);
        return code::success($data);

    }

    /**
     * 获取团队列表
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionGetTeamList(){
        $request =$this->request;
        $model = new Team();
        $params = $request->queryParams;
        $total_data = $model->getTeamList($params);
        $data = tools::getPageData($total_data,empty($params['page_size'])?'':$params['page_size'],empty($params['page'])?'':$params['page']);


        return code::success($data);

    }

    /**
     * 获取项目列表
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionGetProjectList(){
        $request =$this->request;
        $model = new Project();
        $params = $request->queryParams;
        $total_data = $model->getProjectList($params);
        $data = tools::getPageData($total_data,empty($params['page_size'])?'':$params['page_size'],empty($params['page'])?'':$params['page']);
        return code::success($data);

    }

    /**
     * 获取项目详情
     * @author hey_heyang(635870453@qq.com)
     * @return json
     */
    public  function  actionGetProjectDetail(){
        $request =$this->request;
        $model = new Project();
        $params = $request->queryParams;
        if(empty($params['id'])) return code::error('error','id 不能为空');
        $total_data = $model->getProjectDetail($params);
        return code::success($total_data);

    }





}

